package com.stockz.equity.indicator.value;

import java.util.List;

import org.springframework.stereotype.Component;

import com.stockz.equity.indicator.Indicator;
import com.stockz.equity.model.Bar;
import com.stockz.equity.model.Bar.BarValueType;
import com.stockz.equity.util.ListUtil;

@Component
public class ValueIndicator implements Indicator<Object> {
	
	private BarValueType barValueType = BarValueType.AVGTRADESIZE;
	
	@Override
	public double getValue(List<Bar> barList) {
		if(barList == null || barList.isEmpty())
			return 0;
		else
			return barList.get(0).getValue(getBarValueType());
	}
	
	@Override
	public Object getIndicatorConfiguration() {
		return null;
	}

	@Override
	public BarValueType getBarValueType() {
		return barValueType;
	}

	@Override
	public void setBarValueType(BarValueType barValueType) {
		this.barValueType = barValueType;
	}

	@Override
	public double[] getValues(List<Bar> barList) {
		return ListUtil.convert(barList, barValueType);
	}
}
